package com.w2cx.selenium.business;

import com.w2cx.selenium.base.DriverBase;
import com.w2cx.selenium.operate.PoiLibrManaOperate;

public class PoiLibrManaProcess {

    DriverBase driver;
    PoiLibrManaOperate plmh;
    public PoiLibrManaProcess(DriverBase driver){
        this.driver = driver;
        plmh = new PoiLibrManaOperate(driver);
    }


    public void addPoi(String poiName,String locationAddress){

        //点击基础数据管理菜单
        plmh.clickBaseDataManageMenu();
        //点击poi库管理菜单
        plmh.clickPoiLibrManageMenu();
        //点击“添加poi”按钮
        plmh.clickAddPoiBtn();

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        //点击poi分类下拉框
        plmh.clickPoiCategory();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //选择poi分类
        plmh.selectPoiCategory();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //输入poi名称
        plmh.inputPoiName(poiName);
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }



        //点击添加图片按钮
        plmh.clickAddImgBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //调用上传图片脚本
        plmh.execAddImgScript();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }



        //输入定位地址
        plmh.inputLocationAddress(locationAddress);
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //点击定位按钮
        plmh.clickLocationBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        //点击保存按钮
        plmh.clickAddPoiSaveBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }



    }

    //判断是否添加成功
    public boolean addPoiSuccess(String addPoiName){
        driver.refresh();
        System.out.println("poi库添加的poi名称："+plmh.getAlreadyAddPoiName());
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        if(plmh.getAlreadyAddPoiName().contains(addPoiName)){
            return true;
        }else {
            return false;
        }
    }


}
